#-*- coding:utf-8 -*-
from scrapy.spiders import CrawlSpider,Request
from data5u.items import Data5UItem
from scrapy.selector import Selector

class Phone(CrawlSpider):
    name='Phone'
    allowed_domains=[]
    start_url=''
    def __init__(self,word):
        self.word = word
        self.word = self.word.strip()
        self.start_url = "http://www.00cha.com/114.asp?t=%s" % self.word 
    def start_requests(self):
        yield Request(self.start_url,self.phone_parse)
        
    def phone_parse(self,response):
        sel = Selector(response)
        phoneNum = sel.xpath('//*[@id="table1"]/tbody/tr[3]/td[1]/div/b/font/text()').extract()[0]
        numAttribution = sel.xpath('//*[@id="table1"]/tbody/tr[3]/td[1]/div/p[1]/font[1]/b/text()').extract()[0]
        Operator = sel.xpath('//*[@id="table1"]/tbody/tr[3]/td[1]/div/p[1]/font[2]/b/text()').extract()[0]
        print phoneNum,numAttribution,Operator